package com.lablzh.gdxy.repository.activity;

import com.lablzh.gdxy.entity.activity.Project;
import org.springframework.data.domain.Sort;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;

import javax.transaction.Transactional;
import java.util.List;

public interface ProjectRepository extends JpaRepository<Project,Integer> {
    Project findByProjectName(String projectName);

    List<Project> findAllByTeacherUsername(String username, Sort sort);

    @Modifying
    @Transactional
    @Query("update Project set audit=?2 where id=?1")
    void updateAuditById(Integer id, String audit);

    List<Project> findByAudit(String audit,Sort sort);
    @Modifying
    @Transactional
    @Query("update Project set teamID=?2, teamName=?3 where projectName=?1")
    void updateTeamIDAndTeamNameByProjectName(String projectName, Integer teamID, String teamName);
}
